<?php

class General {
	public function team() {
		$results = Mssql::fetch_all('SELECT 
			MEMB_STAT.ConnectStat,
			AccountCharacter.GameIDC,
			Character.Name AS name
			FROM MEMB_STAT 
			JOIN AccountCharacter ON MEMB_STAT.memb___id = AccountCharacter.ID
			JOIN Character ON MEMB_STAT.memb___id = Character.AccountID
			WHERE Character.CtlCode > 7
		');
		$data = array();
		foreach ($results as $key => $value) {
			$value->status = $value->ConnectStat > 0 && $value->GameIDC == $value->name ? 1 : 0;
			unset($value->ConnectStat, $value->GameIDC);
			$data[$key] = $value;
		}
		return $data;
	}
	
	public function server_info($servers) {
		$config = new Config($servers);
		$count = new Count();
		$data = array();
		foreach ($servers as $server) {
			$porcent = Convert::porcent($count->onlines_by_server($server['server']), $server['max']);
			$data[] = array(
				'name' => $server['name'],
				'server' => $server['server'],
				'max' => $server['max'],
				'porcent' => $porcent
			);
		}
		return $data;
	}
}

?>